#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <string>
using namespace std;
#define DEBUG 1
int main() {
    int a = 0;
    cin >> a;
    string s;
    long long ret=0;
    cin >> s;
    int arr[24] = { 0 };
    for (auto i : s)
    {
        arr[i - 'a']++;
    }
#ifdef DEBUG
    for (int i = 0; i < 5; i++)
    {
        cout << arr[i] << ' ';
    }
    cout << endl;
#endif
    for (auto j : s)
    {
        arr[j - 'a']--;
        
        int k = 0;
        while (k < 24)
        {
            if (arr[k] < 2)
            {
                k++;
                continue;
            }
            long long mul = 1;
            if (k == j - 'a')
            {
                k++;
                continue;
            }
            else {
                for (int l = 3; l <= arr[k]; l++)
                {
                    mul *= l;
                }
            }
            ret += mul;
            k++;
        }
    }
    cout << ret;
    return 0;
}